<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2017/1/4
 * Time: 23:27
 */

//mb_strlen — 获取字符串的长度
//mixed mb_strlen ( string $str [, string $encoding = mb_internal_encoding() ] )

$str = "hello 你好";
$hello = "你好";

$mb_strlen = mb_strlen($str);
echo $mb_strlen.PHP_EOL; //8 8
$mb_strlen = mb_strlen($str,"ASCII");
echo $mb_strlen.PHP_EOL;//12 6+2*3
$mb_strlen = mb_strlen($str,"UTF-8");
echo $mb_strlen.PHP_EOL;//8 8
$mb_strlen = mb_strlen($str,"GBK");
echo $mb_strlen.PHP_EOL;//9
$mb_strlen = mb_strlen($hello,"GBK");
echo $mb_strlen.PHP_EOL;//3
$strlen = strlen($str);
echo $strlen.PHP_EOL;//12